require(['swiper','common','loadmore'], function (Swiper) {
  // 轮播
  var swiper = new Swiper('.gzl-swiper', {
    loop: true,
    autoplay: {
      disableOnInteraction: false
    },
    pagination: {
      el: '.swiper-pagination'
    },
  });

  // 滚动冻结
  $(".gzl-section").on("scroll", function () {
    var self = this;
    $.requestAnimationFrame(function () {
      var sTop = self.scrollTop;
      var nTop = $(".channel-page-nav").offset().top + sTop;
      if (nTop < sTop) {
        $(".nav-box").addClass("fixed");
      } else {
        $(".nav-box").removeClass("fixed");
      }
    })
  });

  // 导航
  var navItem = $(".channel-page-nav .gzl-navbar__item");
  $(".channel-page-type").css("min-height", $(window).height() - $(".nav-box").height() - $(".gzl-cell__tips").outerHeight())
  if (navItem.length > 5) {
    navItem.parent().addClass("gzl-navbar_auto");
  }
  navItem.on("click", function () {
    var section = $(".gzl-section");
    section.stop().animate({ scrollTop: $(".channel-page-nav").offset().top + section.scrollTop() }, 300)
  });
  var channelNav = new Swiper('.nav-box', {
    slidesPerView: 5,
    autoHeight: true,
    freeMode: true,
    watchSlidesVisibility: true,
    watchSlidesProgress: true
  });
  var channelNavCon = new Swiper('.channel-page-type', {
    autoHeight: true,
    spaceBetween: 12,
    thumbs: {
      swiper: channelNav
    }
  });

  // 底部回弹
  $('.gzl-section').loadend();
});